package com.sky.controller.user;

import com.sky.dto.OrdersSubmitDTO;
import com.sky.result.Result;
import com.sky.service.OrdersService;
import com.sky.vo.OrderSubmitVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/user/order")
@Api(tags = "C端-订单接口")
@Slf4j
public class OrdersController {

    @Autowired
    private OrdersService ordersService;
    /**
     * 用户下单
     *
     * @param dto
     * @return
     */
    @PostMapping("/submit")
    @ApiOperation("用户下单")
    public Result<OrderSubmitVO> submit(@RequestBody OrdersSubmitDTO dto) {
        log.info("用户下单：dto:{}", dto);
        OrderSubmitVO vo = ordersService.submit(dto);
        return Result.success(vo);
    }

    /**
     * 客户催单操作
     * @param id 订单ID
     * @return Result 操作结果，包含成功状态码
     */
    @GetMapping("/reminder/{id}")
    @ApiOperation("客户催单")
    public Result reminder(@PathVariable Long id){
        // 通过ordersService发送催单通知
        ordersService.reminder(id);
        //传回code信息为必须success中有code
        return Result.success();
    }



}
